import { Get, Controller, Res, UseInterceptors } from '@nestjs/common';
import { Response } from 'express';
import { LoggingInterceptor } from './interceptor/logging.interceptor';
import * as path from 'path';
/**
 * AppController的声明类
 *
 * @export
 * @class AppController
 */
@Controller()
@UseInterceptors(LoggingInterceptor) // 使用LoggingInterceptor
export class AppController {
  // 默认的返回函数 返回html页面
  @Get()
  root(@Res() res: Response) {
    res.sendFile(path.join(__dirname, '../views/index.html'));
  }

  // 当url 为 /hello 时返回 'hello world'
  @Get('/hello')
  hello() {
    return 'hello world';
  }

  // @Get()
  // njs(@Res() res: Response) {
  //   res.render('index', { message: 'Hello Pug' });
  // }
}
